package com.cts.learninglibrary.service.impl;

import com.cts.learninglibrary.dto.ShareDTO;
import com.cts.learninglibrary.mapper.ShareMapper;
import com.cts.learninglibrary.pojo.Share;
import com.cts.learninglibrary.service.ShareService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: kwanghuee
 * @date: 2020/8/18 9:59
 */
@Service
public class ShareServiceImpl implements ShareService {

    @Resource
    private ShareMapper shareMapper;

    @Override
    public int saveShare(ShareDTO shareDTO) {
        return shareMapper.saveShare(shareDTO);
    }

    @Override
    public List<Share> queryByPage(Integer pageNo, Integer pageSize) {
        Map map = new HashMap();
        if (null == pageNo){
            pageNo = 1;
        }
        if (null == pageSize){
            pageSize = 5;
        }

        map.put("startIndex",(pageNo - 1) * pageSize);
        map.put("pageSize",pageSize);

        return shareMapper.queryByParam(map);
    }
}
